
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter3/views/base_page/param_page.dart';

import 'button_page.dart';
import 'entity_page.dart';


class BaseComponentDemo extends StatefulWidget {
  const BaseComponentDemo({Key? key}) : super(key: key);

  @override
  State<BaseComponentDemo> createState() => _BaseComponentDemoState();
}

class _BaseComponentDemoState extends State<BaseComponentDemo>
    with SingleTickerProviderStateMixin {
  final List<String> _tabs = ["button按钮", "实体类定义", "参数详解"];
  final List<Widget> _tabBarViews = [ButtonDemo(),EntityDemo(),ParamDemo()];

  late TabController _controller;
  int _currentIndex = 0;
  @override
  void initState() {
    _controller = TabController(length: _tabs.length, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("ListView组件"),
        centerTitle: true,
        bottom: TabBar(
          controller: _controller,
          tabs: _tabs.map((e) {
            return Tab(text: e);
          }).toList(),
          isScrollable: true, // Tabbar是否可水平滚动
          dragStartBehavior: DragStartBehavior.start, // 默认start 更为平滑
          // physics: ClampingScrollPhysics(), // 滑动到末端时,继续拉动,ClampingScrollPhysics安卓微光效果
          physics: const BouncingScrollPhysics(), // 滑动到末端时,继续拉动,BouncingScrollPhysics苹果回弹效果
          indicator: UnderlineTabIndicator(
              borderSide: BorderSide(color: Colors.red[300]!, width: 2.0),
              insets: const EdgeInsets.symmetric(horizontal: 5.0)),
          onTap: (int index) {
            _currentIndex = index;
            setState(() {

            });
          },
        ),
      ),
      body: TabBarView(
        controller: _controller,
        children: _tabBarViews,
      )
    );
  }
}
